package com.epower.web.action.epoweruserword;

import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.List;
import com.epower.base.BaseAction;
import com.epower.bo.epoweruserword.EpowerUserWordService;
import com.epower.dataobject.EpowerUserWordDO;
import com.opensymphony.xwork2.ActionSupport;

@Scope("prototype")
@Component()
public class EpowerUserWordAction extends BaseAction {
    
	private static final long serialVersionUID = 1L;
	
	/***查询对象 ***/
	private EpowerUserWordDO query;
	
	/***对象集合 ***/
	private List<EpowerUserWordDO> epowerUserWordList;
	
	/*** BO ***/
	private EpowerUserWordService epowerUserWordBO;
	
	/***主键***/
	private Integer id;
	
	/***查询对象 ***/
	private EpowerUserWordDO epowerUserWord;
	
	/***当前action所在的namespace ***/
	private String namespace="epoweruserword";
	/***当前action对应的module ***/
	private String moduleName="EpowerUserWord";
	
	/***
	 * 列表视图
	 * @return
	 * @throws Exception
	 */
	public String listEpowerUserWord() throws Exception {
		//初始化查询条件
		if (query == null) {
			query = new EpowerUserWordDO();
		}
		//查询列表
		epowerUserWordList = epowerUserWordBO.getEpowerUserWordListPageByOption(query);
		pages = this.getPagesList(query.getToPage(), query.getTotalPage());
		return SUCCESS;
	}
	
	/***
	 * 编辑视图
	 * @return
	 * @throws Exception
	 */
	public String viewEditEpowerUserWord() throws Exception{
		epowerUserWord=epowerUserWordBO.getEpowerUserWordById(id);
		return SUCCESS;
	}
	
	/***
	 * 编辑操作
	 * @return
	 * @throws Exception
	 */
	 
	public String editEpowerUserWord()throws Exception{
		if(!epowerUserWordBO.updateEpowerUserWordByOption(epowerUserWord)){
		    addActionMessage("编辑失败");
			return SUCCESS;
		}
		addActionMessage("编辑成功");
		return SUCCESS;
	}
	
	/***
	 * 删除操作
	 * @return
	 * @throws Exception
	 */
	public String deleteEpowerUserWord()throws Exception{
		if(!epowerUserWordBO.deleteEpowerUserWordById(id)){
			addActionMessage("删除失败");
			return SUCCESS;
		}
		addActionMessage("删除成功");
		return SUCCESS;
	}
	/***
	 * 添加视图
	 * @return
	 * @throws Exception
	 */
	public String viewAddEpowerUserWord()throws Exception{
		return SUCCESS;
	}
	
	/***
	 * 添加操作
	 * @return
	 * @throws Exception
	 */
	public String addEpowerUserWord()throws Exception{
		if(epowerUserWordBO.addEpowerUserWord(epowerUserWord)==null){
			addActionMessage("添加失败");
			return SUCCESS;
		}
		addActionMessage("添加成功");
		return SUCCESS; 
	}
	
	
	
	/*** setter getter start***/
	public EpowerUserWordDO getQuery() {
		return query;
	}
	public void setQuery(EpowerUserWordDO query) {
		this.query = query;
	}
	public List<EpowerUserWordDO> getEpowerUserWordList() {
		return epowerUserWordList;
	}
	public void setEpowerUserWordList(List<EpowerUserWordDO> epowerUserWordList) {
		this.epowerUserWordList = epowerUserWordList;
	}
	public EpowerUserWordService getEpowerUserWordBO() {
		return epowerUserWordBO;
	}
	@Resource
	public void setEpowerUserWordBO(EpowerUserWordService epowerUserWordBO) {
		this.epowerUserWordBO = epowerUserWordBO;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public EpowerUserWordDO getEpowerUserWord() {
		return epowerUserWord;
	}
	public void setEpowerUserWord(EpowerUserWordDO epowerUserWord) {
		this.epowerUserWord = epowerUserWord;
	}
	public String getNamespace() {
		return namespace;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}
	
	public String getModuleName() {
		return moduleName;
	}
	public void setModuleName(String moduleName) {
		this.moduleName = moduleName;
	}
	/*** setter getter end***/
}

